import request from '@/utils/request';

/**
 * 查询车辆列表
 */
export async function selectVehicleList(params) {
  return request(`/server/api/tms/tms-vehicle/selectList`, {
    method: 'POST',
    body: params,
  });
}

/**
 * 新增 编辑车辆
 */
export async function vehicleOperate(params) {
  const { id, ...body } = params;
  const url = id ? 'updateVehicle' : 'insertVehicle';
  return request(`/server/api/tms/tms-vehicle/${url}`, {
    method: 'POST',
    body: params,
  });
}

/**
 * 启动和禁用车辆
 */
export async function enableOrDisable(params) {
  const { type, ...body } = params;
  const url = !type ? 'enableVehicle' : 'disabledVehicle';
  return request(`/server/api/tms/tms-vehicle/${url}`, {
    method: 'POST',
    body,
  });
}

/**
 * 车辆详情
 */
export async function vehicleDetail(params) {
  return request(
    `/server/api/tms/tms-vehicle/selectDetails`,
    {
      method: 'POST',
      body: params,
    },
    true
  );
}

/**
 * 证件信息详情
 */
export async function selectInfoDetail(params) {
  return request(`/server/api/tms/tms-vehicle-papers/selectPapersDetails`, {
    method: 'POST',
    body: params,
  });
}

/**
 * 新增编辑 证件
 */
export async function infoOperate(params) {
  const { id, ...body } = params;
  const url = id ? 'updatePapers' : 'insertPapers';
  return request(`/server/api/tms/tms-vehicle-papers/${url}`, {
    method: 'POST',
    body: params,
  });
}
